package com.five.api;

import com.five.dto.UpdateDto;
import com.five.pojo.Author;
import com.five.pojo.Chapter;
import com.five.pojo.Novel;
import com.five.result.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient(name="author-service", contextId = "authorServiceAPI")
public interface AuthorServiceAPI {
    @PostMapping("author/queryByPhone/{phone}")
    public Result<Author> queryByPhone(@PathVariable String phone);

    @PostMapping("author/queryByEmail/{email}")
    public Result<Author> queryByEmail(@PathVariable String email);

    @PostMapping("author/queryByLoginInfoId/{loginInfoId}")
    public Result<Author> queryByLoginInfoId(@PathVariable Long loginInfoId);

    @PostMapping("author/insertAuthor")
    public Result insertAuthor(@RequestBody Author author);

    @PostMapping("author/updateAuthor")
    public Result updateAuthor(@RequestBody Author author);

    /**
     *根据账号查询作者信息
     * @param
     * @return
     */
    @PostMapping("author/queryByAccount/{account}")
    public Result<Author> queryByAccount(@PathVariable String account);

    /**
     * 查询作者的小说列表
     *
     * @param authorId 作者id
     * @return 小说列表
     */
    @PostMapping("/author/novel/novels/{authorId}")
    Result<List<Novel>> queryNovelList(@PathVariable("authorId") Long authorId);

    /**
     * 创建新书
     *
     */
    @PostMapping("/author/novel/add")
    Result<Novel> createNovel(@RequestBody Novel novel);

    /**
     * 删除小说
     */
    @PostMapping("/author/novel/delete/{novelId}")
    Result<Novel> deleteNovel(@PathVariable("novelId") Long novelId);

    /**
     * 更新小说信息
     */
    @PostMapping("/author/novel/update")
    Result<Novel> updateNovel(@RequestBody Novel novel);

    /**
     * 查询小说详情
     */
    @PostMapping("/author/novel/detail/{novelId}")
    Result<Novel> queryNovelDetail(@PathVariable("novelId") Long novelId);

    /**
     * 创建章节
     */
    @PostMapping("/chapter/createChapter")
    Result<String> createChapter(Chapter chapter);

    /**
     * 批量创建章节
     */
    @PostMapping("/chapter/batchAdd")
    Result<String> batchAdd(@RequestBody List<Chapter> chapters);

    /**
     * 更新章节
     */
    @PostMapping("/chapter/updateChapter")
    Result<String> updateChapter(Chapter chapter);
    /**
     * 更新章节状态
     */
    @PostMapping("/chapter/updateStatus")
    Result<String> updateStatus(@RequestBody UpdateDto dto);

    /**
     * 删除章节
     */
    @PostMapping("/chapter/deleteChapter/{chapterId}")
    Result<String> deleteChapter(@PathVariable("chapterId") Long chapterId);

    /**
     * 查询章节列表
     */
    @PostMapping("/chapter/list/{novelId}")
    Result<List<Chapter>> queryChapterList(@PathVariable("novelId") Long novelId);

    /**
     * 查询章节详情
     */
    @PostMapping("/chapter/detail/{chapterId}")
    Result<Chapter> queryChapterDetail(@PathVariable("chapterId") Long chapterId);

    /**
     * 小说总字数更新
     */
    @PostMapping("/author/novel/updateWordCount/{novelId}")
    Result<String> updateNovelWordCount(@PathVariable("novelId") Long novelId, @RequestParam("wordCount") Integer wordCount);

    /**
     * 小说状态更新
     */
    @PostMapping("/author/novel/updateStatus")
    Result<String> updateNovelStatus(@RequestBody UpdateDto dto);
}
